﻿namespace Z2.Editor
{
	using System;
	using System.Collections.Generic;
	using System.Windows.Forms;
	using vKapse.DDTool.Visual;
	using System.Diagnostics;

	static class Program
	{
		
		public static LogListener LogListener { get; private set; }

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			Debug.Listeners.Add(LogListener = new LogListener());
			Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Program.ThreadException);
			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new EditorForm());
		}

		static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
		{
			ExceptionView.Show((Exception)e.ExceptionObject);
		}

		private static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
		{

			ExceptionView.Show(e.Exception);
		}
	}
}
